<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <script src="js/swiper-4.2.6.min.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="css/swiper-4.2.6.min.css"/>
    <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
    <script src="js/public.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/font.js"></script>
    <link rel="stylesheet" href="css/base.css">
    <link rel="stylesheet" href="css/ui.css">
    <title></title>
    <!-- 服务中心-工单-评价 -->
    <style>
    </style>
</head>
<body>
<div class="scroll-content2 my-service-center-evaluate" style="overflow:auto;background: #f1f1f1;">
    <div class="top-public">
        <span class="public-center">用户评价</span>        
        <img src="images/left_icon.png" alt="" class="public-left">
    </div>
    <div class="evaluate-top">
        <p>您对本次服务的评价</p>
        <div class="star-box">
            <img src="images/star2-.png" alt="" onclick="xx(this)">
            <img src="images/star2-.png" alt="" onclick="xx(this)">
            <img src="images/star2-.png" alt="" onclick="xx(this)">
            <img src="images/star2-.png" alt="" onclick="xx(this)">
            <img src="images/star2-.png" alt="" onclick="xx(this)">
        </div>
        <ul>
            <li>产品态度好</li>
            <li>技术能力强</li>
            <li>问题解决很及时</li>
            <li>产品体验好</li>
        </ul>
    </div>
    <div class="evaluate-center">
        <p>您的问题是否解决?</p>
        <ul class="fabulous">
            <li id="1" class="active2"><img src="images/good.png" alt="">已解决</li>
            <li id="2"><img src="images/heta.png" alt="">未解决</li>
        </ul>
    </div>
    <div class="evaluate-bot">
        <p>告诉我们想要反馈的问题</p>
        <textarea name="" id="acquirer" cols="43" rows="7"></textarea>
        <span style="float:right;margin-right: 0.15rem;color: #999;" id="text-num">0/200</span>
    </div>
    <div class="sub-btn" onclick="sub()">提交评价</div>
</div>
</body>
<script>
$('.public-left').click(function(){
    window.history.go(-1);
})
// 字数限制
window.onload = function() {
    //（document）
    document.getElementById('acquirer').onkeyup = function() {        
        document.getElementById('text-num').innerHTML=this.value.length + '/200';
    }
}
// 选择星星
function xx(obj){
    $(obj).attr('src','images/star2.png').prevAll().attr('src','images/star2.png');
    $(obj).nextAll().attr('src','images/star2-.png');
}

$('.evaluate-top ul li').click(function () {
    if($(this).hasClass('active')){
        $(this).removeClass('active')
    }else{
        $(this).addClass('active')
    }
})

$('.evaluate-center ul li').click(function () {
    $(this).addClass('active2').siblings().removeClass('active2');
})


$(function(){
    //验证是否登陆
    var user_id = sessionStorage.getItem('userId');
    if (user_id == null) {
        alert('请先登录！');
        window.location.href = 'login.html';
    }
});

function sub(){
    var user_id = sessionStorage.getItem('userId');
    var wid = sessionStorage.getItem('wid');
    var starnum = 0;     // 星星数
    $.each($('.star-box').children(),function(i,item){
        if($(item).attr("src") == 'images/star2.png'){
            starnum ++;
        }
    });
    var eva_array = [];           //评价 数组 1234
    $.each($('.evaluate-top ul').children(),function(i,item){
        if($(item).hasClass('active')){
            eva_array.push($(item).index()+1)
        }
    });
    var eva_array2 = JSON.stringify(eva_array);
    // console.log(eva_array2);
    var is_solve = $('.fabulous .active2')[0].id; //是否解决（1.解决 2.未解决）
    var acquirer = $('#acquirer').val(); //反馈问题
    
    $.ajax({
        url: url() + 'api/Invoice/workService',    //请求的url地址
        dataType: "JSON",   //返回格式为json
        async: true,//请求是否异步，默认为异步，这也是ajax重要特性
        type: "POST",   //请求方式
        data:{
            wid:wid,
            user_id:user_id,
            evaluation:starnum,
            praise:eva_array2,
            is_solve:is_solve,
            feedback:acquirer
        },
        success: function (data) {
            console.log(data);
            //请求成功时处理
            if(data.status==1){
                window.location.href = 'my_servicecenter_gd_gh.html';
            } else {
                alert(data.msg);
            }
        }
    });
}

</script>
</html> 






